package com.example.handler;

import com.example.entity.SysSms;
import com.example.entity.SysTask;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import java.util.Random;

@Service
public class SysSmsHandler extends AbstractSysTaskHandler {

    Logger logger = LoggerFactory.getLogger(getClass());

    @Override
    public Boolean isMatch(SysTask sysTask) {
        return sysTask.getModelName().equalsIgnoreCase(SysSms.class.getName());
    }

    @Override
    public Boolean isSpeedy() {
        return Boolean.TRUE;
    }

    @Override
    public void handler(SysTask sysTask) throws Exception {
        int size = new Random().nextInt(10);
        Thread.sleep(size * 1000);
        logger.info("SysSmsHandler 发送短信: modelId: {} , modelName: {} ", sysTask.getModelId(), sysTask.getModelName());
    }
}
